package com.goodving.guli.model.uploadhelper.p076b;

import com.goodving.guli.bt.profile.scale.GuliLog;
import com.goodving.guli.model.uploadhelper.C1312a;
import com.goodving.guli.model.uploadhelper.SyncerUpload;
import com.goodving.guli.model.uploadhelper.p074a.C1299b;
import com.goodving.guli.model.uploadhelper.p074a.C1300g;
import com.goodving.guli.model.uploadhelper.p074a.C1304h;
import com.goodving.guli.model.uploadhelper.p074a.C1306a;
import com.goodving.guli.model.uploadhelper.p074a.C1307c;
import com.goodving.guli.model.uploadhelper.p074a.C1308d;
import com.goodving.guli.model.uploadhelper.p074a.C1309e;
import com.goodving.guli.model.uploadhelper.p074a.C1310f;
import com.goodving.guli.model.uploadhelper.p074a.C1311i;

public class C1313a<Data> {
    protected C1299b f6678a;
    protected Data f6679b;

    public C1313a(C1299b c1299b) {
        this.f6678a = c1299b;
    }

    public C1313a(Data data) {
        this.f6679b = data;
    }

    public C1313a m11513a(C1307c c1307c) {
        c1307c.before();
        return this;
    }

    public C1313a m11514a(C1310f c1310f) {
        c1310f.then(this.f6678a.state());
        return this;
    }

    public C1313a m11515a(SyncerUpload c1316d, C1306a c1306a) {
        GuliLog.tracePrintInfo(c1316d.tag(), "Sync Access... : " + this.f6679b);
        C1313a c1313a = new C1313a((C1299b) c1306a);
        try {
            c1313a.m11524a(c1306a.access(this.f6679b));
            GuliLog.tracePrintInfo(c1316d.tag(), "Sync Accessed Data : " + c1313a.f6679b);
            if (c1306a.isEmpty(c1313a.f6679b)) {
                c1306a.exception(new C1312a(17));
            } else if (c1306a.isIdle()) {
                c1306a.success();
            }
        } catch (Throwable e) {
            c1306a.exception(new C1312a(1, e));
        }
        c1306a.logState(c1316d.tag());
        return c1313a;
    }

    public C1313a m11516a(SyncerUpload c1316d, C1308d c1308d) throws C1312a {
        if (this.f6678a != null) {
            if (this.f6678a.isException()) {
                throw this.f6678a.getException();
            } else if (this.f6678a.isPassedon()) {
                return this;
            }
        }
        GuliLog.tracePrintInfo(c1316d.tag(), "Sync Parse...");
        C1313a c1313a = new C1313a((C1299b) c1308d);
        try {
            c1313a.m11524a(c1308d.m11510a(this.f6679b));
            if (c1308d.isIdle()) {
                c1308d.success();
            }
        } catch (Throwable e) {
            c1308d.exception(new C1312a(6, e));
        }
        c1308d.logState(c1316d.tag());
        return c1313a;
    }

    public C1313a m11517a(SyncerUpload d1, C1309e e1) throws C1312a {
        if (this.f6678a != null)
        {
            if (this.f6678a.isException())
            {
                throw this.f6678a.getException();
            }
            if (this.f6678a.isPassedon())
            {
                return this;
            }
        }
        GuliLog.tracePrintInfo(d1.tag(), "Sync Process...");
        try
        {
            e1.m11511a(this.f6679b);
            if (e1.isIdle())
            {
                e1.success();
            }
        }
        catch (Exception exception)
        {
            e1.exception(new C1312a(5, exception));
        }
        e1.logState(d1.tag());
        this.f6678a = e1;
        return this;
    }

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
//    public com.goodving.guli.model.uploadhelper.p076b.C1313a m11517a(com.goodving.guli.model.uploadhelper.SyncerUpload r4, com.goodving.guli.model.uploadhelper.p074a.C1309e r5) {
//        /*
//        r3 = this;
//        r0 = r3.f6678a;
//        if (r0 == 0) goto L_0x001c;
//    L_0x0004:
//        r0 = r3.f6678a;
//        r0 = r0.isException();
//        if (r0 == 0) goto L_0x0013;
//    L_0x000c:
//        r0 = r3.f6678a;
//        r0 = r0.getException();
//        throw r0;
//    L_0x0013:
//        r0 = r3.f6678a;
//        r0 = r0.isPassedon();
//        if (r0 == 0) goto L_0x001c;
//    L_0x001b:
//        return r3;
//    L_0x001c:
//        r0 = r4.tag();
//        r1 = "Sync Process...";
//        cn.com.smartdevices.bracelet.GuliLog.tracePrintInfo(r0, r1);
//        r0 = r3.f6679b;	 Catch:{ Exception -> 0x003d }
//        r5.m11511a(r0);	 Catch:{ Exception -> 0x003d }
//        r0 = r5.isIdle();	 Catch:{ Exception -> 0x003d }
//        if (r0 == 0) goto L_0x0033;
//    L_0x0030:
//        r5.success();	 Catch:{ Exception -> 0x003d }
//    L_0x0033:
//        r0 = r4.tag();
//        r5.logState(r0);
//        r3.f6678a = r5;
//        goto L_0x001b;
//    L_0x003d:
//        r0 = move-exception;
//        r1 = new cn.com.smartdevices.bracelet.i.a;
//        r2 = 5;
//        r1.<init>(r2, r0);
//        r5.exception(r1);
//        goto L_0x0033;
//        */
//        throw new UnsupportedOperationException("Method not decompiled: cn.com.smartdevices.bracelet.i.b.a.a(cn.com.smartdevices.bracelet.i.d, cn.com.smartdevices.bracelet.i.a.e):cn.com.smartdevices.bracelet.i.b.a");
//    }

    public C1313a m11518a(SyncerUpload c1316d, C1300g c1300g) throws C1312a {
        if (this.f6678a == null || !this.f6678a.isException()) {
            GuliLog.tracePrintInfo(c1316d.tag(), "Sync Send...");
            C1313a c1313a = new C1313a((C1299b) c1300g);
            try {
                c1313a.m11524a(c1300g.m11506a(this.f6679b));
                GuliLog.tracePrintInfo(c1316d.tag(), "Sync Send Received : " + c1313a.f6679b);
                if (c1300g.isIdle()) {
                    c1300g.success();
                }
            } catch (Throwable e) {
                c1300g.exception(new C1312a(4, e));
            }
            c1300g.logState(c1316d.tag());
            return c1313a;
        }
        throw this.f6678a.getException();
    }

    public C1313a m11519a(SyncerUpload c1316d, C1304h c1304h) throws C1312a {
        if (this.f6678a == null || !this.f6678a.isException()) {
            GuliLog.tracePrintInfo(c1316d.tag(), "Sync Check...");
            try {
                c1304h.check(this.f6679b);
                if (c1304h.isIdle()) {
                    c1304h.success();
                }
            } catch (Throwable e) {
                c1304h.exception(new C1312a(3, e));
            }
            c1304h.logState(c1316d.tag());
            this.f6678a = c1304h;
            return this;
        }
        throw this.f6678a.getException();
    }

    public C1313a m11520a(SyncerUpload c1316d, C1311i c1311i) throws C1312a {
        if (this.f6678a == null || !this.f6678a.isException()) {
            GuliLog.tracePrintInfo(c1316d.tag(), "Sync Wrap...");
            C1313a c1313a = new C1313a((C1299b) c1311i);
            try {
                c1313a.m11524a(c1311i.wrap(this.f6679b));
                GuliLog.tracePrintInfo(c1316d.tag(), "Sync Wrapped Data : " + c1313a.f6679b);
                if (c1311i.isIdle()) {
                    c1311i.success();
                }
            } catch (Throwable e) {
                c1311i.exception(new C1312a(2, e));
            }
            c1311i.logState(c1316d.tag());
            return c1313a;
        }
        throw this.f6678a.getException();
    }

    public C1313a m11521a(Object obj, C1307c c1307c) {
        c1307c.mArg = obj;
        return m11513a(c1307c);
    }

    public C1313a m11522a(Object obj, C1310f c1310f) {
        c1310f.mArg = obj;
        return m11514a(c1310f);
    }

    public Data m11523a() {
        return this.f6679b;
    }

    public void m11524a(Data data) {
        this.f6679b = data;
    }
}
